package zhao.tx.eecs.Tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDate {
    public static String getFileName() {
        SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd");
        String date = format.format(new Date (System.currentTimeMillis()));
        return date;// 2012年10月03日 23:41:31
    }

    public static String getDateEN() {
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date1 = format1.format(new Date(System.currentTimeMillis()));
        return date1;// 2012-10-03 23:41:31
    }

    public static String getDateEN( long time ) {
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date1 = format1.format(new Date(time* 1000));
        return date1;// 2012-10-03 23:41:31
    }

    public static String getNewDateEN( long time ) {
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date1 = format1.format(new Date(time));
        return date1;// 2012-10-03 23:41:31
    }

    public static String getMyDateEN( long time ) {
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy/MM/dd");
        String date1 = format1.format(new Date(time* 1000));
        return date1;// 2012-10-03 23:41:31
    }

    public static long string2Timestamp(String dateString) {
        Date date1 = null;
        try {
            date1 = new SimpleDateFormat ("yyyy-MM-dd HH:mm").parse(dateString);

            long temp = date1.getTime();//JAVA的时间戳长度是13位
            temp /= 1000;
            return temp;
        } catch ( ParseException e ) {
            e.printStackTrace ();
            return -1;
        }
    }



}